<template>
    <div class="page">
        <div class="page_header" style="display: flex;">
            <div style="flex: 1 1 auto">
                <el-form ref="searchForm" :model="searchForm" style="display: flex;">
                    <el-form-item prop="talent_id">
                        <el-input v-model="searchForm.talent_id" placeholder="编号"></el-input>
                    </el-form-item>
                    <el-form-item prop="nickname">
                        <el-input v-model="searchForm.nickname" placeholder="微信昵称"></el-input>
                    </el-form-item>
                    <el-form-item prop="openid">
                        <el-input v-model="searchForm.openid" placeholder="openid"></el-input>
                    </el-form-item>
                    <el-form-item prop="account_name">
                        <el-input v-model="searchForm.account_name" placeholder="账号昵称"></el-input>
                    </el-form-item>
                    <el-form-item prop="channel_id">
                        <el-select v-model="searchForm.channel_id" multiple placeholder="达人等级">
                            <el-option
                                    v-for="item in channels"
                                    :key="item.value"
                                    :label="item.text"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item prop="status">
                        <el-select v-model="searchForm.status" multiple placeholder="认证状态">
                            <el-option :value="-1" label="资料待完善"></el-option>
                            <el-option :value="0" label="待认证"></el-option>
                            <el-option :value="1" label="认证通过"></el-option>
                            <el-option :value="2" label="认证不通过"></el-option>
                            <el-option :value="3" label="已冻结"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item prop="verify_time">
                        <el-date-picker
                                v-model="searchForm.verify_time"
                                type="datetimerange"
                                value-format="yyyy-MM-dd HH:mm:ss"
                                start-placeholder="认证起期"
                                end-placeholder="认证止期">
                        </el-date-picker>
                    </el-form-item>
                </el-form>
            </div>
            <div style="flex:0 0 auto;">
                <el-button @click="$store.dispatch('tableReload')" type="primary">查询</el-button>
                <el-button @click="$store.dispatch('tableReset')">重置</el-button>
            </div>
        </div>
        <el-card class="page_body">
            <el-table
                    height="10"
                    class="page_body_table"
                    :data="common.tableData"
                    v-loading="common.loading"
                    border
                    stripe
                    style="width: 100%">
                <el-table-column prop="talent_id" width="80" label="id"></el-table-column>
                <el-table-column prop="status_name" width="100" label="状态">
                    <template slot-scope="scope">
                        <el-tag type="info" v-if="scope.row.status === -1">{{scope.row.status_name}}</el-tag>
                        <el-tag v-if="scope.row.status === 0">{{scope.row.status_name}}</el-tag>
                        <el-tag type="success" v-if="scope.row.status === 1">{{scope.row.status_name}}</el-tag>
                        <el-tag type="warning" v-if="scope.row.status === 2">{{scope.row.status_name}}</el-tag>
                        <el-tag type="danger" v-if="scope.row.status === 3">{{scope.row.status_name}}</el-tag>
                    </template>
                </el-table-column>
                <el-table-column prop="status_name" width="100" label="达人">
                    <template slot-scope="scope">
                        <el-tag type="success" v-if="scope.row.intelligent">认证达人</el-tag>
                    </template>
                </el-table-column>
                <el-table-column prop="account_name" label="账号昵称">
                    <template slot-scope="scope">
                        <el-button type="text" @click="$refs.talentDetail.init(scope.row.talent_id)">{{scope.row.account_name}}</el-button>
                    </template>
                </el-table-column>
                <el-table-column prop="channel_name" width="100" label="达人等级"></el-table-column>
                <el-table-column prop="nickname" label="微信昵称"></el-table-column>
                <el-table-column prop="short_name" label="地区"></el-table-column>
                <el-table-column prop="openid" width="240" label="openid"></el-table-column>
                <el-table-column prop="phone" width="120" label="手机号"></el-table-column>
                <el-table-column prop="apply_time" width="150" label="申请时间"></el-table-column>
                <el-table-column prop="verify_time" width="150" label="认证时间"></el-table-column>
            </el-table>
            <pagination class="page_body_pagination"></pagination>
        </el-card>
        <talent-detail-dialog ref="talentDetail" @refresh="$store.dispatch('tableReload')"></talent-detail-dialog>
    </div>
</template>

<script>
    import {mapState} from 'vuex';
    import Pagination from "../Pagination";
    import TalentDetailDialog from "./Dialog/TalentDetailDialog";
    export default {
        name: "Talent",
        computed:{
            ...mapState(['common']),
        },
        components:{
            Pagination,
            TalentDetailDialog,
        },
        data(){
            return{
                method:'post',
                url:'/api/laifei/talent/store',
                searchForm:{
                    talent_id:'',
                    nickname:'',
                    account_name:'',
                    channel_id:[],
                    status:[],
                    verify_time:[],
                },
                channels:[],

            }
        },
        created() {
            this.$store.dispatch('pageInit', this);

            // 加载推广新媒体类型
            this.post('/api/common/enums', {type: 'explore_channel'}).then(result => {
                if (result.code === 0) {
                    this.channels = result.data;
                }
            });
        },
    }
</script>

<style scoped>

</style>
